﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows;
using System.Globalization;

namespace RecommendatioNetwork.View.Converter
{
    class TypologyComboBoxItemToStringConverter : IValueConverter
    {
        //viene invocato al passaggio dalla fonte dati verso l'elelmento di user Interface
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            ComboBoxItem cbi = new ComboBoxItem();
            cbi.Content = value;
            return cbi;
        }

        //viene invocato al passaggio dalla user Interface alla fonte dati
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                return "";
            ComboBoxItem cbi = value as ComboBoxItem;
            return cbi.Content.ToString();
        }
    }

}




